<?php

/**
 * This is the model class for table "EP_TO_USER_DEF".
 *
 * The followings are the available columns in table 'EP_TO_USER_DEF':
 * @property integer $ID
 * @property string $EP_ALIAS
 * @property string $PPR_USER_ID
 * @property string $PHONE_ID
 * @property string $LINE_ID
 * @property string $VALUE
 * @property string $VALUE_TYPE
 * @property integer $CUST_ID
 * @property string $CARD_PIN
 *
 * The followings are the available model relations:
 * @property USERDEF $pPRUSER
 * @property CUSTOMER $cUST
 */
class EPTOUSERDEF extends OrcActiveRecord//Lưu thông tin 
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return EPTOUSERDEF the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'EP_TO_USER_DEF';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('EP_ALIAS, PPR_USER_ID', 'required'),
			array('CUST_ID', 'numerical', 'integerOnly'=>true),
			array('EP_ALIAS', 'length', 'max'=>32),
			array('PPR_USER_ID', 'length', 'max'=>24),
			array('PHONE_ID, LINE_ID', 'length', 'max'=>3),
			array('VALUE', 'length', 'max'=>25),
			array('VALUE_TYPE', 'length', 'max'=>10),
			array('CARD_PIN', 'length', 'max'=>12),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID, EP_ALIAS, PPR_USER_ID, PHONE_ID, LINE_ID, VALUE, VALUE_TYPE, CUST_ID, CARD_PIN', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'pPRUSER' => array(self::BELONGS_TO, 'USERDEF', 'PPR_USER_ID'),
			'cUST' => array(self::BELONGS_TO, 'CUSTOMER', 'CUST_ID'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID' => 'ID',
			'EP_ALIAS' => 'Ep Alias',
			'PPR_USER_ID' => 'Ppr User',
			'PHONE_ID' => 'Phone',
			'LINE_ID' => 'Line',
			'VALUE' => 'Value',
			'VALUE_TYPE' => 'Value Type',
			'CUST_ID' => 'Cust',
			'CARD_PIN' => 'Card Pin',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID',$this->ID);
		$criteria->compare('EP_ALIAS',$this->EP_ALIAS,true);
		$criteria->compare('PPR_USER_ID',$this->PPR_USER_ID,true);
		$criteria->compare('PHONE_ID',$this->PHONE_ID,true);
		$criteria->compare('LINE_ID',$this->LINE_ID,true);
		$criteria->compare('VALUE',$this->VALUE,true);
		$criteria->compare('VALUE_TYPE',$this->VALUE_TYPE,true);
		$criteria->compare('CUST_ID',$this->CUST_ID);
		$criteria->compare('CARD_PIN',$this->CARD_PIN,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}